﻿using System;

namespace DimensionsHelper.Common.Contracts.Excel;

/// <summary>
///     Excel单元格边框的当前样式。
/// </summary>
public struct ExcelBorderState
{
    /// <summary>
    ///     边框样式，默认是<see cref="BorderStyle.None" />
    /// </summary>
    public BorderStyle BorderStyle;

    /// <summary>
    ///     颜色值索引，默认是0.
    /// </summary>
    public int IndexedColor;

    /// <summary>
    ///     颜色的RGB值
    /// </summary>
    public string? Rgb;

    /// <summary>
    ///     主题颜色
    /// </summary>
    public int? ThemeColor;

    /// <summary>
    ///     判断当前颜色是否未配置
    /// </summary>
    /// <returns></returns>
    public readonly bool IsColorEmpty()
    {
        return IndexedColor == 0 && Rgb == null && ThemeColor == null;
    }

    /// <summary>
    ///     判断当前边框是否未设置
    /// </summary>
    /// <returns></returns>
    public readonly bool IsEmpty()
    {
        return BorderStyle == BorderStyle.None && IsColorEmpty();
    }

    /// <summary>
    ///     判断当前设定的颜色是否和给定颜色相同。
    /// </summary>
    /// <param name="color">给定颜色</param>
    /// <returns>如果颜色相同，返回true，否则，返回false</returns>
    public readonly bool IsSameColor(ExcelStyleColor color)
    {
        return Rgb != null && Rgb.Equals(color.ToString(), StringComparison.OrdinalIgnoreCase);
    }
}